<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>商品管理</title>
		<script src="../js/mui.min.js"></script>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../css/shop1.css" />
		<link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../css/web.css" />
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav public-color">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">商品管理</h1>
		</header>
		<div class="mui-content sp_edit">
			<div class="spedit_top clearfix">
				<!--<div class="spedit_tl">
					<div class="mui-input-row mui-checkbox mui-left">
					  <label>全选</label>
					  <input name="checkbox1" type="checkbox" >
					</div>					
					<a class="spedit_del" href="#"><span class="mui-icon iconfont icon-shanchu"></span>删除</a>
				</div>-->
				<a href="goodcreate.html"><div class="spedit_tr" >添加商品</div></a>
			</div>
			
			<ul class="speidt_list" id="store1">
		<!--		<li class="clearfix">
					<div class="mui-input-row mui-checkbox mui-left">
					  <input name="checkbox1" type="checkbox">
					</div>
					<div class="spe_lisimg"><img src="../img/cpimg.png"></div>
					<div class="spe_lisinfo">
						<p class="spe_lisnam">苏泊尔/SUPOR炫彩无油烟不粘锅4件套</p>
						<p class="spe_lispri">￥<em>99</em></p>
					</div>
					<div class="spe_lisbtn">
						<p class="edit_btn">编辑</p>
						<p class="delete_btn">删除</p>
					</div>
				</li>-->
				
			</ul>
		</div>
		<div id="footer"></div>
	</body>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/app.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/castapp.js"></script>
<script type="text/javascript" src="../js/layer/layer.min.js"></script>
	<script>
	$(function() {
//	alert('ok')
	dlpd();
	get_navigation();
getFoot(getUrlParam("foot_active") > 0 ? getUrlParam("foot_active") : 4);
			

		var loading = layer.load(0, {
			shade: false,
			time: 1 * 1000
		});
		var member=JSON.parse(localStorage.getItem('member'));
			$.ajax({
				//type: 'post',
				url: APP.api_url + 'goods/bianji',
				data: {
					member_id:member['id']
				},
				dataType:'jsonp',
				success: function(data) {
					if(data.code == 200) {
						var json = data.data;						
						var store_htm = "";
						if(json.length !=0 ){
							for(var i = 0; i < json.length; i++) {
							var strs=json[i].content.split("@");
					store_htm += '<li class="clearfix">'+
					'<div class="mui-input-row mui-checkbox mui-left">'+
					  '<input name="checkbox1" type="checkbox">'+
					'</div><div class="spe_lisimg"><img src="'+APP.pic_url+strs[0]+'"></div>'+
					'<div class="spe_lisinfo"><p class="spe_lisnam">'+json[i].goods_name+'</p><p class="spe_lispri">￥<em>'+json[i].price+'</em></p>'+
					'</div><div class="spe_lisbtn"><p class="edit_btn" onclick="bian('+json[i].id+')">编辑</p><p class="delete_btn" onclick="shan('+json[i].id+')">删除</p>'+
					'</div></li>';
							}
						}else{
							store_htm+='<h3>您还没有商品，赶快添加吧</h3>';
						}
						document.getElementById("store1").innerHTML=store_htm;
					} else {
						console.log(data.msg);
					}
				}
			});
			
	});		
			//编辑
			function bian(id){
				localStorage.setItem('goods_id', id);
				window.location.href="goodsbj.html";    
			}
			
			//删除
			function shan(id){
			layer.confirm('是否确定删除？', {
   			 btn: ['确定','取消'] //按钮
			}, function(){
			$.ajax({
				type:"post",
				url:APP.api_url + "goods/shan1",
				data:{goods_id:id},
				dataType:'jsonp',
				success:function(data){
				if(data.code==200){
						layer.msg(data.msg,{icon:2,time:1500,shade: 0.1}, function(index){
						window.location.href="";    
                		});
					}else{
							layer.msg(data.msg,{icon:2,time:1500,shade: 0.1}, function(index){
							window.location.href="";    
                		});
					}
			
				},
	
					});
			});
	
			}
	</script>

</html>